package com.da.javatest.niuke.jianzhi;

import java.util.ArrayList;

/**
 * @author chenlida
 * @date 2020/10/27 14:44
 * https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C64Solution {
    public static ArrayList<Integer> maxInWindows(int[] num, int size) {
        ArrayList<Integer> list = new ArrayList<>();
        if (size > num.length || size < 1) {
            return list;
        }
        for (int i = 0; i <= num.length - size; i++) {
            int max = Integer.MIN_VALUE;
            for (int j = i; j < size + i; j++) {
                max = Math.max(max, num[j]);
            }
            list.add(max);
        }
        return list;
    }

    public static void main(String[] args) {
        System.out.println(maxInWindows(new int[] {2, 3, 4, 2, 6, 2, 5, 1}, 3));
    }
}
